package com.liyongjian.page.dal;


import java.util.Date;

import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.repository.query.Param;

import com.liyongjian.page.domain.ReportForm;

public interface ReportFormRepository extends PagingAndSortingRepository<ReportForm, Long> {

    @Modifying
    @Query("update ReportForm t set t.count=t.count + :count, t.addCount=t.addCount + :count where t.name=:name and to_days(t.repAt)=to_days(:repAt)")
    int updateByKeysAndRepAt(@Param("name") String name, @Param("repAt") Date repAt,
            @Param("count") Integer count);

    @Query("select max(t.addCount) from ReportForm t where t.name=:name")
    Integer findByKeys(@Param("name") String name);

}
